Skip to content

Add inlineDataParts accessor for GenerateContentResponse #14755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 23, 2025

Conversation

paulb777
Copy link
Member

This should match the Android and JS implementations

google-labs-jules bot and others added 2 commits April 22, 2025 21:51
Adds a new computed property `inlineDataParts` to `GenerateContentResponse` to provide easier access to inline data parts (like images) within the model's response.

This property iterates through the parts of the first candidate and filters for `InlineDataPart` instances. Error handling is included for cases with no candidates or no inline data parts.

Unit tests have been added in `GenerativeModelTests.swift` to validate the functionality of the new property, covering scenarios with and without inline data, and responses with no candidates.
Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

@paulb777
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request adds an inlineDataParts accessor to the GenerateContentResponse struct, mirroring implementations in Android and JS. The code includes appropriate logging and unit tests, which is great. Here are a few suggestions for improvement.

Summary of Findings

  • Clarity of Log Message: The log message could be more specific about the context in which the inline data parts are being accessed. Consider adding information about which candidate is expected to contain the inline data.
  • Test Coverage: While the unit tests cover cases with and without inline data, consider adding a test case where multiple candidates exist, but only the first one is checked for inline data parts. This would more closely reflect the intended behavior of the accessor.
  • Naming Consistency: Consider renaming inlineData to inlineDataParts for consistency with the accessor name inlineDataParts.

Merge Readiness

The code changes seem to be in good shape, but there are a few suggestions for improvement. I would recommend addressing these before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.

@google-oss-bot
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

paulb777 and others added 2 commits April 22, 2025 15:19
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Contributor

@andrewheard andrewheard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so far (will review the tests tomorrow). Thanks!

Copy link
Contributor

@andrewheard andrewheard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (assuming I didn't break CI when moving the tests to a new file). Thanks for adding this!

@paulb777 paulb777 merged commit 2b68801 into main Apr 23, 2025
37 checks passed
@paulb777 paulb777 deleted the feature/inline-data-parts branch April 23, 2025 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants